%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for mutations/v4/sub.insert_x"
    Bucket0("Bucket 0 (root)"):::bucket
    Bucket1("Bucket 1 (mutationField)<br />Deps: 12, 13, 18, 19<br /><br />1: PgSelect[9]<br />2: PgSelectRows[15]<br />ᐳ: 14, 16, 17"):::bucket
    Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 17, 16, 9, 19<br /><br />ROOT Object{1}ᐸ{result}ᐳ[17]"):::bucket
    Bucket3("Bucket 3 (nullableBoundary)<br />Deps: 16, 9, 19<br /><br />ROOT PgSelectSingle{1}ᐸinsert_xᐳ[16]"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket2
    Bucket2 --> Bucket3

    %% plan dependencies
    __InputObject6{{"__InputObject[6∈0] ➊<br />More deps:<br />- Constantᐸundefinedᐳ[7]<br />- Constantᐸ'Foo'ᐳ[24]"}}:::plan
    Object12{{"Object[12∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    Access10{{"Access[10∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access11{{"Access[11∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access10 & Access11 --> Object12
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access10
    __Value2 --> Access11
    PgFromExpression13{{"PgFromExpression[13∈0] ➊<br />More deps:<br />- Constantᐸ'Foo'ᐳ[24]"}}:::plan
    ApplyInput18{{"ApplyInput[18∈0] ➊"}}:::plan
    __InputObject6 --> ApplyInput18
    PgSelect9[["PgSelect[9∈1] ➊<br />ᐸinsert_x(mutation)ᐳ"]]:::sideeffectplan
    Object12 & PgFromExpression13 & ApplyInput18 --> PgSelect9
    First14{{"First[14∈1] ➊"}}:::plan
    PgSelectRows15[["PgSelectRows[15∈1] ➊"]]:::plan
    PgSelectRows15 --> First14
    PgSelect9 --> PgSelectRows15
    PgSelectSingle16{{"PgSelectSingle[16∈1] ➊<br />ᐸinsert_xᐳ"}}:::plan
    First14 --> PgSelectSingle16
    Object17{{"Object[17∈1] ➊<br />ᐸ{result}ᐳ"}}:::plan
    PgSelectSingle16 --> Object17
    List21{{"List[21∈3] ➊<br />ᐸ19,20ᐳ<br />More deps:<br />- Constantᐸ'xes'ᐳ[19]"}}:::plan
    PgClassExpression20{{"PgClassExpression[20∈3] ➊<br />ᐸ__insert_x__.”id”ᐳ"}}:::plan
    PgClassExpression20 --> List21
    PgSelectSingle16 --> PgClassExpression20
    Lambda22{{"Lambda[22∈3] ➊<br />ᐸbase64JSONEncodeᐳ"}}:::plan
    List21 --> Lambda22
    PgClassExpression23{{"PgClassExpression[23∈3] ➊<br />ᐸ__insert_x__.”name”ᐳ"}}:::plan
    Object17 o--o PgClassExpression23

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,__InputObject6,Access10,Access11,Object12,PgFromExpression13,ApplyInput18 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,PgSelect9,First14,PgSelectRows15,PgSelectSingle16,Object17 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2 bucket2
    classDef bucket3 stroke:#ffa500
    class Bucket3,PgClassExpression20,List21,Lambda22,PgClassExpression23 bucket3

